<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/bootstrap.css" />
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<title>里斯点餐系统</title>
</head>

<script type="text/javascript">

	function isEmpty(obj){
		if(obj.val()==""||obj.val().trim()==""){
			return true;
		}
		return false;
	}
	function callback(data){
		$("chname").html(data);
	}
	$(function(){
		/*为用户名输入框绑定失去焦点事件，当失去焦点时，设置其后的输出提示文本  */
		$("#name").blur(function(){
			
			if(isEmpty($(this))){
				$("#chname").html("<font font-size='9px' color='red'>用户名不能为空！</font>");
			}else{
				$("chname").html("");
				$.ajax({
					url:"LoginServlet?name="+$(this).val(),
					type:"GET",
					datatype:"html",
					async:true,
					success:callback
				});
			}
		});
		/*为密码输入框绑定失去焦点事件，当失去焦点时，设置其后的输出提示文本  */
		$("#password").blur(function(){
			if(isEmpty($(this))){
				$("#chpassword").html("<font font-size='9px' color='red'>密码不能为空！</font>");
			}else{
				$("#chpassword").html("");
			}
		});
	});
	
</script>
<body>

<form class="form-horizontal" role="form" action="ActionServlet?action=login" method="post">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">用户名：</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" name="name" id="name" placeholder="请输入用户名"><label id="chname"></label>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">密码：</label>
    <div class="col-sm-10">
      <input type="password" class="form-control" name="password" id="password" placeholder="请输入密码"><label id="chpassword"></label>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <div class="checkbox">
        <label>
          <input type="checkbox" name="savepwd" value="savepwd"> 记住密码
        </label>
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">登录</button><a href="ActionServlet?action=register">没有账号？注册</a>
    </div>
  </div>
</form>

</body>
</html>
